<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="zh-CN">
<head>
<link rel="stylesheet" href="<%=path%>/css/manager/organization.css">
<link rel="stylesheet" href="<%=path%>/css/page.css">
<script type="text/javascript"
	src="<%=path%>/js/manager/jquery-1.8.2.js"></script>
<script type="text/javascript"
	src="<%=path%>/js/manager/organization.js"></script>
<script type="text/javascript" src="<%=path%>/js/page.js"></script>
<title>论坛管理-机构</title>
</head>
<body>
	<!--
        	作者：offline
        	时间：2016-12-22
        	描述：论坛内容头部（统一，部分二级字体颜色单独修改）
        -->
	<div class="news_div1">
		<div class="news_div1_div1">论坛管理</div>
		<div class="news_div1_div2">
			<a href="<%=path%>/basicctr/bbsbasic.htm?markManage=3"
				class="news_div1_div2_div1">论坛概况</a> <a>|</a> <a href="###"
				class="news_div1_div2_div2  ablack">机构设置</a> <a>|</a> <a
				href="<%=path%>/newsctr/newslist.htm?pageIndex=1&pageSize=10&newsType=4"
				class="news_div1_div2_div3">理事动态</a>
		</div>
	</div>
	<!--机构内容-->
	<div class="bbs_mist_div2">
		<input class="bbs_mist_div2_in1" type="button"
			onclick="manage(1,0,0,0)" />
		<div class="bbs_mist_div2_div1">
			<div class="bbs_mist_div2_div1_div1">机构名称</div>
			<div class="bbs_mist_div2_div1_div2">操作</div>
		</div>
		<div class="bbs_mist_div2_div2">
			<c:forEach items="${list}" var="organzies">
				<div class="bbs_mist_div2_div2_div1">
					<div class="bbs_mist_div2_div2_div1_div1">
						<a href="###">${organzies.orgName}</a>
					</div>
					<div class="bbs_mist_div2_div2_div1_div2">
						<a
							href="javascript: manage(4,'${organzies.orgId}','${organzies.orgName}','${organzies.orgContent}')">查看</a>
						<a
							href="javascript: manage(2,'${organzies.orgId}','${organzies.orgName}','${organzies.orgContent}')">编辑</a>
						<a href="javascript: manage(3,'${organzies.orgId}',0,0)">删除</a>
					</div>
				</div>
			</c:forEach>
		</div>
		<div class="bbs_mist_div2_div3">
			<select onchange="setPageSize()" id="pageSize_sel">
				<option
					<c:if test="${banner.pageInfo.pageSize==10}">selected="selected"</c:if>>10</option>
				<option
					<c:if test="${banner.pageInfo.pageSize==15}">selected="selected"</c:if>>15</option>
				<option
					<c:if test="${banner.pageInfo.pageSize==20}">selected="selected"</c:if>>20</option>
			</select> <span>/每页，共${organize.pageInfo.totalRec}条记录</span>
		</div>
		<div class="page">
			<!-- 分页 -->
			<c:set value="${organize.pageInfo}" var="pageInfo"></c:set>
			<%@include file="../template/pageTemplate.jsp"%>
		</div>
	</div>
	<!--机构添加-->
	<div class="organization">
		<form action="omanage.htm" id="sform" method="post">
			<input type="hidden" id="sysuserId" name="orgAdduser"
				value="${back_user.sysuserId}" /> <input type="hidden"
				id="pageIndex" name="pageIndex"
				value="${organize.pageInfo.pageIndex}" /> <input type="hidden"
				id="pageSize" name="pageSize" value="${organize.pageInfo.pageSize}" /><input
				type="hidden" id="markManage" name="markManage" value="0" /> <input
				type="hidden" id="orgId" name="orgId" value="0" /><input
				type="hidden" id="orgContent" name="orgContent"
				value="${organize.orgContent}" />
			<div class="organization_div1">
				<div class="organization_div1_div1">添加机构</div>
				<div class="organization_div1_div2">
					<div class="organization_div1_div2_div1">机构名称</div>
					<input class="organization_div1_div2_in1" type="text"
						placeholder="机构名称" name="orgName" id="orgName" value="" />
				</div>
				<div class="organization_div1_div3">
					<div class="organization_div1_div3_div1">机构内部名称</div>
					<div class="organization_div1_div3_div2">
					</div>
					
					<div class="clearboth"></div>
				</div>
				<input class="organization_div1_in1" type="button" />
				<div class="organization_div1_div4">
					<input class="organization_div1_div4_in1" type="submit" value=""
						onclick="return submitCheck()" /> <input
						class="organization_div1_div4_in2" type="button" />
				</div>
			</div>
		</form>
	</div>
</body>
<script type="text/javascript">
//操作：type:1添加；2编辑；3删除 4查看
function manage(type,id,name,content){
	 
	if(type==1){
		$(".organization").css({"display":"block"});
		$("#orgName").val("");
		$("#markManage").val(1);
		$("#orgId").val(0);
		$(".organization_div1_div3_div2").html("");
		$(".organization_div1_div3_div2").append($('<div class="organization_div1_div3_div2_div1"><input type="text" placeholder="机构内部名称（一次仅输入一个)" value="" name="content"/></div>'));
	}else if(type==2){
		$(".organization").css({"display":"block"});
		$("#markManage").val(2);
		$("#orgId").val(id);
		$("#orgName").val(name);
		$(".organization_div1_div3_div2").html("");
		if(content.length==0){
			$(".organization_div1_div3_div2").append($('<div class="organization_div1_div3_div2_div1"><input type="text" placeholder="机构内部名称（一次仅输入一个)" value="" name="content"/></div>'));
			return ;	
		}
		var array=content.split("@##");
		for(var i=0;i<array.length;i++){
			if(i==0){
			$(".organization_div1_div3_div2").append($('<div class="organization_div1_div3_div2_div1"><input type="text" placeholder="机构内部名称（一次仅输入一个)" value="'+array[i]+'" name="content"/></div>'));
			}else{
			$(".organization_div1_div3_div2").append($('<div class="organization_div1_div3_div2_div1"><input type="text" placeholder="机构内部名称（一次仅输入一个)" value="'+array[i]+'" name="content"/><img class="organization_div1_div3_div2_div1_img1" src="<%=path%>/images/manager/organization_03s.jpg" /></div>'));
			}
		}
		
	}else if(type==3){
		if(window.confirm("确定要删除该机构吗？")){
			$("#markManage").val(3);
			$("#orgId").val(id);
			$("#pageIndex").attr("name","pageInfo.pageIndex");  
			$("#pageSize").attr("name","pageInfo.pageSize");  
			$("#sform").submit();
         } 
	}else if(type==4){
		$("#orgId").val(id);
		$("#markManage").val(4);
		$("#sform").attr("action", "goomanage.htm");
		$("#pageIndex").attr("name","pageInfo.pageIndex");  
		$("#pageSize").attr("name","pageInfo.pageSize");  
		$("#sform").submit();
	}
	
}
//提交验证
function submitCheck(){
	//验证管理员登录
	var sysuserId=$("#sysuserId").val();
	if(sysuserId.length==0){
		alert("管理员登录失效，请重新登录");
		window.open("<%=path%>/login/beforelogin.htm");
			return false;
		}
		//验证机构
		var orgName = $("#orgName").val();
		if (orgName.length == 0) {
			alert("机构名称不能为空！");
			$("#orgName").focus();
			return false;
		} else {
			$("#orgName").val(orgName);
		}
		//内部机构
		var array = document.getElementsByName("content");
		var content = "";

		for (var i = 0; i < array.length; i++) {
			if (array[i].value.length > 0) {
				content = content + array[i].value + "@##";
			}
		}
		content = content.substring(0, content.length - 3);
		if (content.length > 0) {
			$("#orgContent").val(content);
		}
		$("#pageIndex").attr("name","pageInfo.pageIndex");  
		$("#pageSize").attr("name","pageInfo.pageSize");  
		return true;

	}
</script>
</html>

